<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">
    <h:head >

    </h:head>
    <h:body onload="document.getElementById('form1:codigo').focus()">
        <ui:composition template="#{mudarTemplateBean.template}">
            <ui:define name="centro">
                <!--p:messages globalOnly="true" showDetail="true" /-->

                <div id="divCentro">
                    <p:messages globalOnly="true" showDetail="true" />
                    <p:panel header="Cadastro de Clientes" visible="true" toggleable="true" styleClass="painelCentral" >
                      <h:outputLabel value="Dados pessoais" style="font-style: oblique; font-style: italic; font-weight: bolder; font-size: larger  "/>
                     <h:form id="form1">

                            <h:inputHidden value="#{manterClienteBean.cliente.codigo}"/>
                             <!--h:selectOneRadio id="cpfCnpj" value="#{manterClienteBean.cliente.cpfcnpj}"
                                                  title="#{mens.MENSAGEMRADIO}">
                                    <f:selectItem itemLabel="CNPJ" itemValue="#{true}"/>
                                    <f:selectItem itemLabel="CPF"  itemValue="#{false}"/>
                                    <p:ajax update="CNPJ, CPF" event="change" />
                                </h:selectOneRadio-->

                             <!--h:outputLabel value="#{mens.CNPJ}"/>
                                <p:inputMask id="CNPJ"   size="20" mask="99.999.999/9999-99"
                                             disabled="#{manterClienteBean.cliente.cpfcnpj ? false : true}"
                                             required="true"
                                             value="#{manterClienteBean.cliente.cpfcnpj}"
                                             title="#{mens.MENSAGEMCNPJ}">
                                </p:inputMask>
                                <p:message for="CNPJ" /-->


                            <h:panelGrid  id="panelPessoal"  columns="6"     >

                                <h:outputText value="#{mens.NOME}" />
                                <p:inputText id="nome" value="#{manterClienteBean.cliente.nome}" required="true" size="30" title="#{mens.MENSAGEMNOME}"/>
                                <p:message for="nome"/>



                                <h:outputLabel value="#{mens.CPF}" />
                                <p:inputMask  id="CPF"   size="20" mask="999.999.999-99"
                                              required="true"
                                              value="#{manterClienteBean.cliente.cpfcnpj}"
                                              title="#{mens.MENSAGEMCPF}">
                                </p:inputMask>
                                <p:message for="CPF" />

                                <h:outputText value="#{mens.TELEFONE}" />
                                <p:inputMask id="telefone" mask="(99)9999-9999"  value="#{manterClienteBean.cliente.telefone}" size="30" title="#{mens.MENSAGEMTELEFONE}" />
                                <p:message for="telefone"/>

                                <h:outputText value="#{mens.CELULAR}" />
                                <p:inputMask id="celular"  mask="(99)9999-9999"   value="#{manterClienteBean.cliente.celular}" size="30" title="#{mens.MENSAGEMCELULAR}" />
                                <p:message for="celular"/>

                            </h:panelGrid>
                            <p:separator />
                            <h:outputLabel value="#{mens.ENDERECO}" style="font-style: oblique; font-style: italic; font-weight: bolder; font-size: larger "/>

                            <h:panelGrid id="panelEndereco" columns="6" >
                                <h:outputText value="#{mens.PAIS}" styleClass="outputText"/>
                                <p:inputText id="pais" value="#{manterClienteBean.endereco.pais}" size="25" required="true">
                                    <f:validateLength for="pais" maximum="100"/>
                                </p:inputText>
                                <p:message for="pais"/>

                                <h:outputText value="#{mens.ESTADO}" styleClass="outputText"/>
                                <p:inputText id="estado" value="#{manterClienteBean.endereco.estado}" size="25" required="true">
                                    <f:validateLength for="estado" maximum="100"/>
                                </p:inputText>
                                <p:message for="estado"/>

                                <h:outputText value="#{mens.CIDADE}" styleClass="outputText"/>
                                <p:inputText id="cidade" value="#{manterClienteBean.endereco.cidade}" size="25" required="true">
                                    <f:validateLength for="cidade" maximum="100"/>
                                </p:inputText>
                                <p:message for="cidade"/>

                                <h:outputText value="#{mens.BAIRRO}" styleClass="outputText"/>
                                <p:inputText id="bairro" value="#{manterClienteBean.endereco.bairro}" size="25" required="true">
                                    <f:validateLength for="bairro" maximum="100"/>
                                </p:inputText>
                                <p:message for="bairro"/>

                                <h:outputText value="#{mens.RUA}" styleClass="outputText"/>
                                <p:inputText id="rua" value="#{manterClienteBean.endereco.rua}" size="25" required="true">
                                    <f:validateLength for="rua" maximum="100"/>
                                </p:inputText>
                                <p:message for="rua"/>

                                <h:outputText value="#{mens.NUMERO}" styleClass="outputText"/>
                                <p:inputText id="numero" value="#{manterClienteBean.endereco.numero}" size="25" required="true">
                                    <f:validateLength for="numero" maximum="100"/>
                                </p:inputText>
                                <p:message for="numero"/>

                                <h:outputText value="#{mens.CEP}" styleClass="outputText"/>
                                <p:inputMask id="cep" mask="99.999-999" value="#{manterClienteBean.endereco.cep}" size="25" required="true"/>
                                <p:message for="cep"/>

                                <h:outputText value="#{mens.COMPLEMENTO}" styleClass="outputText"/>
                                <p:inputText id="complemento" value="#{manterClienteBean.endereco.complemento}" size="25" required="true">
                                    <f:validateLength for="complemento" maximum="500"/>
                                </p:inputText>
                                <p:message for="complemento"/>
                            </h:panelGrid>
                            <p:separator />

                            <h:panelGrid columns="3">
                                <p:commandButton ajax="false" value="#{mens.INSERIR}" action="#{manterClienteBean.create}" />
                                <p:commandButton ajax="false" value="#{mens.ALTERAR}" action="#{manterClienteBean.edit}" disabled="#{manterClienteBean.naoSelecionouCliente}"/>
                                <p:commandButton ajax="false" value="#{mens.EXCLUIR}" action="#{manterClienteBean.destroy}" disabled="#{manterClienteBean.naoSelecionouCliente}"/>
                            </h:panelGrid>


                        </h:form>

                        <h:form>
                            <h:panelGrid>
                                <p:panel header="Pesquisar Por">
                                    <h:selectOneMenu >
                                        <f:selectItem itemLabel=""/>
                                        <f:selectItem itemLabel="Nome"/>
                                        <f:selectItem itemLabel="Codigo"/>

                                    </h:selectOneMenu>
                                    <p:inputText  style="margin-left: 5px"/>
                                    <p:commandButton ajax="false" value="#{mens.PESQUISAR}" action="#{manterClienteBean.findClienteEntities}" image="url(../img/pesquisa2.png)" />

                                </p:panel>
                            </h:panelGrid>

                        </h:form>
                    </p:panel>
                    <h:form>
                        <p:panel  header="Painel de pesquisa" visible="true" toggleable="true" styleClass="painelCentral">
                            <p:dataTable style="width:620px "  paginator="true" rows="4" paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="5" emptyMessage="#{mens.TABELA_VAZIA}" value="#{manterClienteBean.clientes}" var="p" rendered="#{manterClienteBean.exibeTabela}">
                                <p:column>
                                   <h:commandLink value="#{p.nome}" action="paginaManterCliente.xhtml">
                                        <f:setPropertyActionListener value="#{p.nome}" target="#{manterClienteBean.cliente.nome}"/>
                                        <f:setPropertyActionListener value="#{p.cpfcnpj}" target="#{manterClienteBean.cliente.cpfcnpj}"/>
                                        <f:setPropertyActionListener value="#{p.telefone}" target="#{manterClienteBean.cliente.telefone}"/>
                                        <f:setPropertyActionListener value="#{p.celular}" target="#{manterClienteBean.cliente.celular}"/>
                                        <f:setPropertyActionListener value="#{p.endereco}" target="#{manterClienteBean.endereco}"/>
                                        <f:setPropertyActionListener value="#{p.codigo}" target="#{manterClienteBean.cliente.codigo}"/>
                                        <f:setPropertyActionListener value="false" target="#{manterClienteBean.naoSelecionouCliente}"/>
                                    </h:commandLink>
                                </p:column>

                                <p:column>
                                    <f:facet name="header">#{mens.NOME}</f:facet>
                                    <h:outputText value="#{p.nome}"/>
                                </p:column>

                                <p:column>
                                    <f:facet name="header">#{mens.CPFCNPJ}</f:facet>
                                    <h:outputText value="#{p.cpfcnpj}"/>
                                </p:column>

                                <p:column>
                                    <f:facet name="header">#{mens.TELEFONE}</f:facet>
                                    <h:outputText value="#{p.telefone}"/>
                                </p:column>

                                <p:column>
                                    <f:facet name="header">#{mens.CELULAR}</f:facet>
                                    <h:outputText value="#{p.celular}"/>
                                </p:column>

                                <p:column>
                                    <f:facet name="header">#{mens.ENDERECO}</f:facet>
                                    <h:outputText value="#{p.endereco}"/>
                                </p:column>

                                <p:column>
                                        <f:facet name="header">
                                            <h:outputText value="#{mens.ENDERECO}"/>
                                        </f:facet>
                                        <h:form>

                                            <h:outputText value="#{p.endereco.pais}"/>
                                            <h:outputText value=", "/>

                                            <h:outputText value="#{p.endereco.estado}"/>
                                            <h:outputText value=", "/>


                                            <h:outputText value="#{p.endereco.cidade}"/>
                                            <h:outputText value=", "/>


                                            <h:outputText value="#{p.endereco.bairro}"/>
                                            <h:outputText value=", "/>


                                            <h:outputText value="#{p.endereco.rua}"/>
                                            <h:outputText value=", "/>


                                            <h:outputText value="#{p.endereco.numero}"/>
                                            <h:outputText value=", "/>


                                            <h:outputText value="#{p.endereco.cep}"/>
                                            <h:outputText value=", "/>


                                            <h:outputText value="#{p.endereco.complemento}"/>

                                        </h:form>
                                    </p:column>

                            </p:dataTable>
                        </p:panel>
                    </h:form>
                </div>
            </ui:define>
        </ui:composition>
    </h:body>
</html>
